package com.shop.entity;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import org.hibernate.annotations.GenericGenerator;

/**
 * Product entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "product", catalog = "myshop")
public class Product implements java.io.Serializable {

	// Fields

	private Integer epId;
	private ProductCategory productCategory;
	private String epName;
	private String epDescription;
	private Float epPrice;
	private Integer epStock;
	private String epFileName;
	private Set<OrderDetail> orderDetails = new HashSet<OrderDetail>(0);
	private Set<News> newses = new HashSet<News>(0);

	// Constructors

	/** default constructor */
	public Product() {
	}

	/** full constructor */
	public Product(ProductCategory productCategory, String epName,
			String epDescription, Float epPrice, Integer epStock,
			String epFileName, Set<OrderDetail> orderDetails, Set<News> newses) {
		this.productCategory = productCategory;
		this.epName = epName;
		this.epDescription = epDescription;
		this.epPrice = epPrice;
		this.epStock = epStock;
		this.epFileName = epFileName;
		this.orderDetails = orderDetails;
		this.newses = newses;
	}

	// Property accessors
	@GenericGenerator(name = "generator", strategy = "increment")
	@Id
	@GeneratedValue(generator = "generator")
	@Column(name = "ep_id", unique = true, nullable = false)
	public Integer getEpId() {
		return this.epId;
	}

	public void setEpId(Integer epId) {
		this.epId = epId;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "epc_id")
	public ProductCategory getProductCategory() {
		return this.productCategory;
	}

	public void setProductCategory(ProductCategory productCategory) {
		this.productCategory = productCategory;
	}

	@Column(name = "ep_name", length = 20)
	public String getEpName() {
		return this.epName;
	}

	public void setEpName(String epName) {
		this.epName = epName;
	}

	@Column(name = "ep_description", length = 100)
	public String getEpDescription() {
		return this.epDescription;
	}

	public void setEpDescription(String epDescription) {
		this.epDescription = epDescription;
	}

	@Column(name = "ep_price", precision = 12, scale = 0)
	public Float getEpPrice() {
		return this.epPrice;
	}

	public void setEpPrice(Float epPrice) {
		this.epPrice = epPrice;
	}

	@Column(name = "ep_stock")
	public Integer getEpStock() {
		return this.epStock;
	}

	public void setEpStock(Integer epStock) {
		this.epStock = epStock;
	}

	@Column(name = "ep_file_name", length = 200)
	public String getEpFileName() {
		return this.epFileName;
	}

	public void setEpFileName(String epFileName) {
		this.epFileName = epFileName;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "product")
	public Set<OrderDetail> getOrderDetails() {
		return this.orderDetails;
	}

	public void setOrderDetails(Set<OrderDetail> orderDetails) {
		this.orderDetails = orderDetails;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "product")
	public Set<News> getNewses() {
		return this.newses;
	}

	public void setNewses(Set<News> newses) {
		this.newses = newses;
	}

}